#include<iostream>
using namespace std;
class Date {
public:
	void Solution(const int year, int n) {
		int days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (IsLeadYear(year))
			days[2]++;
		int i = 1;
		while (n > days[i]) {
			n -= days[i];
			i++;
		}
        _year = year;
		_month = i;
		_day = n;
	}

	bool IsLeadYear(const int year) {
		return (!(year % 4) && (year % 100)) || !(year % 400);
	}
    
     void PutDate()const{
        if(_month < 10 && _day < 10)
            cout << _year << '-' << 0 << _month << '-' << 0 << _day << endl;      
        else if(_month < 10)
            cout << _year << '-' << 0 << _month << '-' << _day << endl;
        else if(_day < 10)
            cout << _year << '-' << _month << '-' << 0 << _day << endl;         
        else
            cout << _year << '-' << _month << '-' << _day << endl;  
    }
    
private:
	int _year;
	int _month;
	int _day;
};

int main() {
	int year, n;
    while(cin >> year >> n){
        Date d;
        d.Solution(year, n);
        d.PutDate();
    }
	return 0;
}
